package com.bank.controller;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bank.exception.CommonException;
import com.bank.service.OrganizationService;
/**
 *  机构挂管理类视图
 * @author shan
 *
 */
@Controller
public class OrganizationController extends BaseController{
	
	Logger logger = Logger.getLogger(OrganizationController.class);

	@Autowired
	OrganizationService organizationService;
	
	/**
	 * 增加机构
	 * @param params
	 * @return
	 * @throws CommonException
	 */
	@RequestMapping(value="addOrganization.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object> addOrganization(@RequestBody Map<String,Object> params) throws CommonException{
		logger.debug("开始调用增加机构");
		organizationService.saveOrganization(params);
		return this.setAndGetSuccess();		
	}
	
	/**
	 * 更新机构信息
	 * @param params
	 * @return
	 * @throws CommonException
	 */
	@RequestMapping(value="updateOrganization.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object> updateOrganization(@RequestBody Map<String,Object> params) throws CommonException{
		logger.debug("开始调用更新机构");
		organizationService.updateOrganization(params);
		return this.setAndGetSuccess();
	}
	
	/**
	 * 查询机构列表信息
	 * @param params
	 * @return
	 */
	@RequestMapping(value="getOrganizationList.do", method=RequestMethod.POST)
	public @ResponseBody Map<String,Object>  getOrganizationList(@RequestBody Map<String,Object> params){
		//查询机构列表
		List<Object> value = organizationService.getOrganizationList(params);
		this.setMapListValue("data", value);
		return this.returnMap();
	}
	
}
